<?php

namespace apiend\modules\user\controllers;

use Yii;
use apiend\components\Controller;
use apiend\modules\user\models\ContentReportForm;

/**
 * 用户设置
 * ThirdPartyController
 */
class SettingController extends Controller {

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    /**
     * 消息通知
     * @return mixed
     */
    public function actionPush() {
        $model = new ContentReportForm();
        $model->user_id = $this->uid;
        if (!$model->load(Yii::$app->request->post(), '')) {
            return parent::error('参数校验失败');
        }
        if (!$model->save()) {
            return $model->dumpError('举报失败');
        }
        return true;
    }

}
